summaryrefslogtreecommitdiff
path: root/src/pages/[locale]/news/index.astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/[locale]/news/index.astro')
-rw-r--r--src/pages/[locale]/news/index.astro6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pages/[locale]/news/index.astro b/src/pages/[locale]/news/index.astro
index 37e7dd6..112f87b 100644
--- a/src/pages/[locale]/news/index.astro
+++ b/src/pages/[locale]/news/index.astro
@@ -5,12 +5,14 @@ import Page from '$layouts/Page.astro';
import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath';
import localeStaticPaths from '$lib/localeStaticPaths';
import { getCollection } from 'astro:content';
-import { isNewsItemInLocale } from '$lib/newsUtils';
+import { isBefore, isNewsItemInLocale } from '$lib/newsUtils';
import NewsIndex from '$components/NewsIndex/NewsIndex.astro';
const allNews = await getCollection('news');
const locale = getLocaleFromPathOrThrow(Astro.url.pathname);
-const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale));
+const allNewsInLocale = allNews
+ .filter((item) => isNewsItemInLocale(item, locale))
+ .sort((a, b) => (isBefore(a, b) ? 1 : isBefore(b, a) ? -1 : 0));
const t = translate(locale);
export async function getStaticPaths() {